package com.glls.lambda.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * @date 2022/10/3
 * @desc
 */


public class Student implements Comparable<Student> {
    private Integer stuNo;

    private String name;

    private Integer age;

    private Double score;


    public Integer getStuNo() {
        return stuNo;
    }

    public void setStuNo(Integer stuNo) {
        this.stuNo = stuNo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Double getScore() {
        return score;
    }

    public void setScore(Double score) {
        this.score = score;
    }

    public Student() {
        System.out.println("调用了无参构造");
    }

    public Student(String name) {
        this.name = name;
        System.out.println("调用了一个String类型参数的构造");
    }

    public Student(Integer age) {
        this.age = age;
        System.out.println("调用了一个Integer类型参数的构造");
    }

    public Student(Integer stuNo,Integer age) {
        this.age = age;
        this.stuNo = stuNo;
        System.out.println("调用了两个Integer类型参数的构造");
    }

    public Student(Integer stuNo, String name, Integer age, Double score) {
        this.stuNo = stuNo;
        this.name = name;
        this.age = age;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuNo=" + stuNo +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        // 比较规则
        return this.getScore()-o.getScore()>0?1:-1;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return stuNo.equals(student.stuNo) && name.equals(student.name) && age.equals(student.age) && score.equals(student.score);
    }

    @Override
    public int hashCode() {
        return Objects.hash(stuNo, name, age, score);
    }
}
